<?php
/**
 * 产品控制器
 *
 * @category     Shuxun Cms
 * @date         2015年10月18日
 * @author       Shuxun Team <kaiping.jiang@scshux.com>
 * @file         PageController.php
 */
namespace Scshux\Front\Controllers;
use Scshux\Utils\JSON;
use Scshux\Mvc\SModel;
use Scshux\Utils\Uploader;
use Scshux\Mvc\SQuery;
use Scshux\Plugin\Wechat;
use Scshux\Utils\Helper;
use Scshux\Tag\SmartyTag;
class PageController extends  ControllerBase
{
	/**
	 * 文章详细
	 */
	public  function  indexAction()
	{	
		$id = $this->request->get('id','int',0);
		if(empty($id)){
			$this->redirect('');
		}

		if ($id == 43)
		{
		    //@date 2015-12-19 联系我们单独处理
		    $this->redirect('page/contact');
		}
		//新增语言过滤
		$site_id = $this->getCore()->getSiteID();
		
		/**读取信息**/
		$helpQuery = new SQuery('help as h');
		$helpQuery->join = 'join help_category as c on h.cat_id=c.id';
		$helpQuery->fields = 'h.*,c.name as cat_name,c.banner as c_banner';
		$helpQuery->where =' h.id='.$id .' and h.site_id='.$site_id;
		
		$help = $helpQuery->find();
		if(empty($help)){
			$this->redirect('');
		}
		$help = $help[0];

		/**读取分类下所有的文章**/
		$helpModel = new SModel('help');
		$helpitems = $helpModel->query(
				' cat_id='.$help->cat_id .' and site_id='.$site_id.' ',
				'cat_id,id,name'
		);

		//处理展示类型
		if($help->type == 1){//图片展示
			$help->pics = explode(';', $help->pics);
		}

		if(!empty($help->timezone)){
			$help->timezone = unserialize($help->timezone);
		}

		$this->view->setVar('help', $help);
		$this->view->setVar('helpitems', $helpitems);
		$this->view->setVar('seo_title', $help->name);
		$this->view->setVar('seo_keywords', $help->seo_keywords);
		$this->view->setVar('seo_description', $help->seo_description);
        
	}


	/**
	 * 联系我们页面较复杂，单独处理 
	 * @author JasonCao
	 * #date 2015-12-19
	 */
	public function contactAction()
	{
		$this->view->setVar('config', $this->getConfig());
	}
	
	/**
	 * 联系我们的地图部分，iframe加载
	 * @author JasonCao
	 * #date 2015-12-19
	 */
	public function contactmapAction()
	{
	    
	}
	
}